Label

Kind of class:class
Inherits from:UIComponent < MovieClip
Classpath:gfx.controls.Label
File last modified:Wednesday, 30 June 2010, 09:09:04
The CLIK Label component is a noneditable standard textField wrapped by a MovieClip symbol, with a few additional convenient features. Internally, the Label supports the same properties and behaviors as the standard textField, however only a handful of commonly used features are exposed by the component itself. Access to the Label’s actual textField is provided if the user needs to change its properties directly. In certain cases, such as those described below, developers may use the standard textField instead of the Label component.

Since the Label is a MovieClip symbol, it can be embellished with graphical elements, which is not possible with the standard textField. As a symbol, it does not need to be configured per instance like textField instances. The Label also provides a disabled state that can be defined in the timeline. Whereas, complex AS2 code is required to mimic such behavior with the standard textField.

The Label component uses constraints by default, which means resizing a Label instance on the stage will have no visible effect at runtime. If resizing textFields is required, developers should use the standard textField instead of the Label in most cases. In general, if consistent reusability is not a requirement for the text element, the standard textField is a lighter weight alternative than the Label component.


Inspectable Properties
The inspectable properties of the Label component are:
  • text: Sets the text of the Label.
  • visible: Hides the label if set to false.
  • disabled: Disables the label if set to true.
  • autoSize: Determines if the button will scale to fit the text that it contains and which direction to align the resized button. Setting the autoSize property to autoSize="none" will leave its current size unchanged.
  • enableInitCallback: If set to true, _global.CLIK_loadCallback() will be fired when a component is loaded and _global.CLIK_unloadCallback will be called when the component is unloaded. These methods receive the instance name, target path, and a reference the component as parameters. _global.CLIK_loadCallback and _global.CLIK_unloadCallback should be overriden from the game engine using GFx FunctionObjects.
States
The CLIK Label component supports two states based on the disabled property.
  • A default or enabled state.
  • a disabled state.
Events
All event callbacks receive a single Object parameter that contains relevant information about the event. The following properties are common to all events.
  • type: The event type.
  • target: The target that generated the event.
The events generated by the Label component are listed below. The properties listed next to the event are provided in addition to the common properties.
  • show: The component’s visible property has been set to true at runtime.
  • hide: The component’s visible property has been set to false at runtime.
  • stateChange: The label’s state has changed.
    • state: The new label state. String type. Values "default" or "disabled".
Component metadata:
    InspectableList
    "autoSize"
    "disabled"
    "enableInitCallback"
    "textID"
    "visible"

    Summary


    Constructor
    Instance properties
    • textField
      • A reference to the TextField instance.
    • textID
      • Set the text parameter of the component using the Locale class to look up a localized version of the text from the Game Engine.
    • text
      • The text to be displayed by the Label component.
    • htmlText
      • The html text to be displayed by the label component.
    • disabled
    • autoSize
      • Determines if the component will scale to fit the text that it contains.
    Class methods
    Class methods inherited from UIComponent
    Instance methods
    • setSize
      • Sets the width and height of the component at the same time using internal sizing mechanisms.

    Constructor

    Label

    function Label (
    )

    The constructor is called when a Label or a sub-class of Label is instantiated on stage or by using attachMovie() in ActionScript. This component can not be instantiated using new syntax. When creating new components that extend Label, ensure that a super() call is made first in the constructor.

    Instance properties

    autoSize

    autoSize:String
    (read,write)

    Determines if the component will scale to fit the text that it contains. Setting the autoSize property to false will leave its current size unchanged.

    disabled

    disabled:Boolean
    (read,write)

    htmlText

    htmlText:String
    (read,write)

    The html text to be displayed by the label component. This property assumes that localization has been handled externally.

    text

    text:String
    (read,write)

    The text to be displayed by the Label component. This property assumes that localization has been handled externally.

    textField

    textField:TextField
    (read,write)

    A reference to the TextField instance. Note that when state changes are made, the textField instance may change, so changes made to it externally may be lost.

    textID

    textID:String
    (read,write)

    Set the text parameter of the component using the Locale class to look up a localized version of the text from the Game Engine. This property can be set with ActionScript, and is used when the text is set using the Component Inspector.
    See also:

    Instance methods

    setSize

    function setSize (
    width:Number, height:Number) : Void

    Sets the width and height of the component at the same time using internal sizing mechanisms.
    Parameters:
    width :
    The new width of the component.
    height:
    The new height of the component.